package com.retail.shop.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.shop.entity.request.RetailAdminShopRequest;
import com.retail.shop.entity.vo.RetailAdminShopVo;
import com.retail.shop.service.RetailAdminShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 用户管理单位 API
* @author Administrator
*/
@Api(tags = "用户管理单位 API")
@RestController
@RequestMapping("/retailAdminShop")
public class RetailAdminShopController extends AbstractCommonController<RetailAdminShopService, RetailAdminShopRequest, RetailAdminShopVo>{

    private final RetailAdminShopService retailAdminShopService;

    public RetailAdminShopController(RetailAdminShopService retailAdminShopService) {
        this.retailAdminShopService = retailAdminShopService;
    }

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(retailAdminShopService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存用户管理单位")
    public Result<Integer> save(@RequestBody RetailAdminShopRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(retailAdminShopService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新用户管理单位")
    public Result<Integer> update(@RequestBody RetailAdminShopRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(retailAdminShopService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("用户管理单位-查询")
    public Result<List<RetailAdminShopVo>>listPage(@RequestBody ParamReq<RetailAdminShopRequest> req) {
        return super.listPage(retailAdminShopService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("用户管理单位-统计")
    public Result<Integer> countPage(@RequestBody ParamReq<RetailAdminShopRequest> req) {
        return super.countPage(retailAdminShopService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("用户管理单位-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<RetailAdminShopRequest> req) {
        return super.page(retailAdminShopService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除用户管理单位")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(retailAdminShopService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除用户管理单位")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(@PathVariable("ids") List<Long> ids) {
        return super.batchDelete(retailAdminShopService, ids);
    }

    @TraceLog()
    @ApiOperation("审核信息")
    @PostMapping("examineVerify")
    public Result<Integer> examineVerify(@RequestBody RetailAdminShopRequest request) {
        return retailAdminShopService.examineVerify(request);
    }
    
    
    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
